package com.second.market.service.impl;

import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.second.common.pojo.RR;
import com.second.market.mapper.CustomerPlaceMapper;
import com.second.market.pojo.entity.Advertise;
import com.second.market.pojo.entity.TbCustomerIssues;
import com.second.market.pojo.entity.TbCustomerPlace;
import com.second.market.pojo.vo.CustomerPlaceVo;
import com.second.market.service.CustomerPlaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: clms-second
 * @description: 位置管理的实现类
 * @author: 邓衡
 * @create: 2021-07-24 18:42
 **/
@Service
public class CustomerPlaceServiceImpl implements CustomerPlaceService {

    @Autowired
    private CustomerPlaceMapper customerPlaceMapper;
    @Override
    public RR fincustomerPlaceByPage(Integer currentPage, Integer pageSize, CustomerPlaceVo customerPlaceVo) {
        Page<TbCustomerPlace> page=new Page<>(currentPage,pageSize);
        QueryWrapper<TbCustomerPlace> wrapper=new QueryWrapper<>();

        if (StringUtils.isNotEmpty(customerPlaceVo.getName())){
            wrapper.like("name",customerPlaceVo.getName());
        }

//        if (StringUtils.isNotEmpty(customerPlaceVo.getPlace())){
//            wrapper.like("place",customerPlaceVo.getPlace());
//        }

        Page<TbCustomerPlace> page1 = customerPlaceMapper.selectPage(page, wrapper);
        return RR.ok().put("records",page1.getRecords()).put("total",page1.getTotal());
    }

    //添加
    @Override
    public RR insert(TbCustomerPlace tbCustomerPlace) {
        int i=customerPlaceMapper.insert(tbCustomerPlace);
        return RR.ok();
    }

    @Override//修改
    public RR update(TbCustomerPlace tbCustomerPlace) {
        int update = customerPlaceMapper.updateById(tbCustomerPlace);
        return RR.ok();
    }

    @Override//根据id回显
    public RR selectById(Integer id) {
        TbCustomerPlace tbCustomerPlace=customerPlaceMapper.selectById(id);
        return RR.ok().put("huixian",tbCustomerPlace);
    }

    //删除
    @Override
    public RR delete(Integer id) {
        int i = customerPlaceMapper.deleteById(id);
        return RR.ok();
    }




}
